'/
' MOTEP - Massive Online Text Environment Project
' --------------------------------------------------------------------------------
' Shared Code
' 
' Strings.bmx
' 
' (c) Anton Berlin. All Rights Reserved.
'/


'// Hashing type. Don't create instances of this. It's mainly meant to be used to prevent name clashing.
type hash



'// -------------------------------------------------------------------------------------------------------------------
'// Description:
'// 		Create a hash using salting on a string, and then the SHA-256 algorithm to generate the hash from that.
'//		Should be pretty secure. Might change the SHA-256 algorithm to the Whirlpool algorithm later on.
'// 
'// Parameters:
'//		(string) src: The string to hash.
'// -------------------------------------------------------------------------------------------------------------------
function CreateHash:string(src:string)

	if (str.length(src) > 6) ..
		return null
	
	'// Salt the string.
	d = "<<]+\&%}"
	d :+ str.substring(src, 0, 2)
	d :+ "#@[-$|"
	d :+ str.reverse(str.substring(src, 2, 3))
	d :+ "\'/=;])"
	d :+ str.substring(src, 5)
	d :+ "~__#"
	
	if (str.length(src) & 1) ..
		d = str.reverse(d)
	
	'// Return a hash of the salted string, using Sha256().
	return Sha256(d)

end function



'// end of type: hash
end type
